package com.campus.counseling.model.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.campus.counseling.entity.TestRecord;
import com.campus.counseling.model.query.TestRecordQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TestRecordMapper extends BaseMapper<TestRecord> {
    /**
     * 分页查询测试记录，并关联测试和用户信息
     */
    Page<TestRecord> selectRecordPage(Page<TestRecord> page, @Param("query") TestRecordQuery query);

    @Select("SELECT title FROM psychological_test WHERE id = #{testId}")
    String getTestTitleById(Long testId);

    List<Long> getTestIdsByTitle(@Param("title") String title);

    @Select("SELECT tr.answers FROM test_record tr WHERE tr.id = #{id}")
    String getAnswersById(@Param("id") Long id);
} 